<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <!--   interceptor.js 一定要在axios后面 -->
    <script src="../plugins/interceptor.js"></script>
    <style>
        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }

        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>预约管理
            <small>手机预约</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>预约管理</el-breadcrumb-item>
            <el-breadcrumb-item>手机预约</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="姓名" prop="name">
                <el-input type="name" v-model="ruleForm.name" ></el-input>
            </el-form-item>
            <el-form-item label="性别" >
                    <el-radio v-model="ruleForm.sex" label="1" border>男</el-radio>
                    <el-radio v-model="ruleForm.sex" label="2" border>女</el-radio>
            </el-form-item>
            <el-form-item label="电话号码" prop="telephone">
                <el-input v-model.number="ruleForm.telephone"></el-input>
            </el-form-item>
            <el-form-item label="身份证号" prop="idCard">
                <el-input v-model.number="ruleForm.idCard"></el-input>
            </el-form-item>
            <el-form-item label="体检日期" >
                <el-date-picker
                        v-model="orderDate"
                        type="date"
                        placeholder="选择日期"
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="套餐列表">
                <el-select v-model="id" placeholder="请选择预约套餐">
                    <el-option
                            v-for="item in setmeals"
                            :label="item.name"
                            :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm()">提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</div>

</body>

<script>
    var vue = new Vue({
        el: '#app',
        data: {
            ruleForm:{},
            setmeals: [],
            id:'',
            rules: {//校验规则
                name: [{ required: true, message: '项目编码为必填项', trigger: 'blur' }],
                telephone: [{ required: true, message: '项目名称为必填项', trigger: 'blur' }]
            },
            orderDate:""
        },

        created() {
            axios.post("/appointment/findAllSetmeals.do").then((res) => {
                this.setmeals = res.data.data;
            })
        },
        methods: {
            submitForm() {
                this.ruleForm.setmealId = this.id;
                this.ruleForm.orderDate = this.orderDate;
                console.log(this.ruleForm);
                axios.post("/appointment/submit.do",this.ruleForm).then( (res) =>  {
                    this.$message({
                        message: res.data.message,
                        type: res.data.flag ? 'success' : "error"
                    });
                })
            },
        }

    })
</script>
</html>
